#include <stdio.h>
#include <stdlib.h>

int* getAverages(int* nums, int numsSize, int k, int* returnSize) {
    long sum=0;
    int *ret=malloc(sizeof(int)*numsSize);
    *returnSize=numsSize;
    for( int i=0; i < numsSize; i++ ){
        sum+=nums[i];
        if( i-k<0 || i+k>=numsSize )
            ret[i]=-1;
        if( i < 2*k ){
            continue;
        }
        ret[i-k]= sum/(2*k+1);
        sum-=nums[i-2*k];
    }
    return ret;
}

int main(){
    //int nums[]={7,4,3,9,1,8,5,2,6};
    int nums[]={8};
    int re;
    int *a=getAverages(nums,sizeof(nums)/sizeof(int),100000,&re);
    for( int i=0; i<re; i++ )
        printf("%d ",a[i]);
    return 0;
}
